/*
*/

#ifndef __PCASE_H
#define __PCASE_H

/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"


#ifdef DEBUG
#define	ASSERT(x,y)	Assert(x,y)
#else
#define	ASSERT(x,y)
#endif

#define	BEAM_LEN	512

#define	EVN_NULL	0
#define	EVN_KEYPRESS	0x01000000
#define	EVN_KEYRELEASE	0x02000000
#define	EVN_MAX		0x03000000
#define	EVN_MASK	0xff000000

#define	KEY____1	1
#define	KEY____2	2
#define	KEY____3	3
#define	KEY____4	4
#define	KEY____5	5
#define	KEY____6	6
#define	KEY____7	7

#define	KEY____8	8
#define	KEY____9	9
#define	KEY____0	10
#define	KEY_DIGI	11
#define	KEY_DISP	12
#define	KEY_TVAV	13
#define	KEY_MUTE	14
#define	KEY_PWER	15

#define	KEY_CHLD	16
#define	KEY_CHLI	17
#define	KEY_VOLD	18
#define	KEY_VOLI	19
#define	KEY_MENU	20
#define	KEY_ENTR	21
#define	KEY_EXIT	22
#define	KEY_INFO	23

#define	KEY_OKEY	24
#define	KEY_RGHT	25
#define	KEY_DOWN	26
#define	KEY_LEFT	27
#define	KEY_UPPP	28
#define	KEY_RESERVED_1	29
#define	KEY_PLAY	30
#define	KEY_PULS	31

#define	KEY_STOP	32
#define	KEY_EJCT	33
#define	KEY_RECR	34
#define	KEY_FRWD	35
#define	KEY_BKWD	36
#define	KEY_PREV	37
#define	KEY_NEXT	38
#define	KEY_STTL	39

#define	KEY_ANGL	40
#define	KEY_ZOOM	41
#define	KEY_LANG	42
#define	KEY_RESERVED_2	43
#define	KEY_RESERVED_3	44
#define	KEY_RESERVED_4	45
#define	KEY_RESERVED_5	46
#define	KEY_RESV	47

#define	KEY_PRESTORE	48
#define	KEY_RESERVED_8	49
#define	KEY___TV	50
#define	KEY_CABL	51
#define	KEY__DVD	52
#define	KEY__AUX	53
#define	KEY_AC		54
#define	KEY_LT		55	//56-60
#define	KEY_STAR	61
#define	KEY_BACK	62
#define	KEY_PROG	63
#define	KEY_MAX		64

#define	PAG_TV		0
#define	PAG_CBL		1
#define	PAG_DVD		2
#define	PAG_AUX		3
#define	PAG_MAX		4

#define	STT_CONTROL	0
#define	STT_SEARCH	1
#define	STT_SIGNAL	2
#define	STT_TEST	3
#define	STT_PRESET	4
#define	STT_LEARNING	5

#define	WAV_NIL		0xffff

typedef struct _BEAM{
    u16	key;
    u16	period;
    u16	pulse;
    u16	repetition;
    u16	timeout;
    u16	head;
    u16	tail;
    u16	wave[BEAM_LEN];
}BEAM;

typedef struct _KEY{
    u8	vendor;
    u8	extra;
    u16	data1;
    u32	data2;
}KEY;

extern	u32	clock;
extern	u32	t_indicate;
extern	u32	page;
extern	u32	status;
extern	BEAM	beam;
extern	BEAM	signal;
extern	KEY	keywave[];

void	Assert	(u8*,u32);
void	Dummy	(void);
void	Fault	(void);

#endif
